<?php
/**
 * Extension de Zend_Debug
 *
 * @package zfbook
 * @subpackage debug
 */
class Zfbook_Debug extends Zend_Debug 
{
    
    /**
     * Appel du __toString en priorité au dump
     *
     * @param mixed $var
     * @param string $label
     * @param boolean $echo
     * @return string
     */
    public static function dump($var, $label = null, $echo = true)
    {
        if (is_object($var)) {
            if (method_exists($var, '__toString')) {
                $var = $var->__toString();
            }
        }
        return parent::dump($var, $label, $echo);
    }
    
    /**
     * Retourne la trace des appels
     *
     * @param boolean $echo
     * @return string
     */
    public static function dumpBackTrace($echo = true)
    {
        $backtrace = debug_backtrace();
        array_shift($backtrace);
        return '<pre>' . print_r($backtrace, true) . '</pre>';
    }
}
